package tests;

import static org.junit.Assert.*;

import java.util.Date;
import java.util.LinkedList;

import junit.framework.TestCase;

import interfaces.IItem;

import org.junit.Before;
import org.junit.Test;

import tests.mocks.*;

public class TestMocks extends TestCase {
	private ISearchSubSupplierMock subSupplier;
	private IItemCacheMock cache;
	private IItemMock item;
	
	
	@Before
	public void setUp() throws Exception {
		subSupplier = new ISearchSubSupplierMock();
		cache = new IItemCacheMock();
		item = new IItemMock();
	}
	
	@Test
	public void testSupplierMock(){
		assertNotNull(subSupplier.LookUpItem(0, ""));
		LinkedList<IItem> items = new LinkedList<IItem>();
		items.add(new IItemMock());
		subSupplier.addItems(items);
		assertEquals(subSupplier.LookUpItem(0, "").size(),1);
	}
	
	@Test
	public void testCacheMock(){
		assertNotNull(cache.LookUpItem(0, ""));
		LinkedList<IItem> items = new LinkedList<IItem>();
		items.add(new IItemMock());
		cache.AddItems(items);
		assertEquals(cache.LookUpItem(0, "").size(),1);
		cache.RemoveItems(items);
		assertTrue(cache.LookUpItem(0, "").isEmpty());
	}

	@Test
	public void testIItemMock(){
	    assertNull(item.getHit());
	    item.setHit(new Date());
	    assertNotNull(item.getHit());	
		assertEquals(item.getSubSupplier(),0);	
		item.setSubSupplier(0);
		assertEquals(item.getPartNumber(),0);
		item.setPartNumber(0);
		assertEquals(item.getDescription(),"");
		item.setDescription("");
	}
    

}
